********************************
***Generate Payment Variables***
********************************


*Administrative payment measure (code or name match)
codebook paid_receipt_admin
label var paid_receipt_admin "Paid property tax (admin data match)"

*Receipt-based payment measure (HH shows valid receipt to enumerator) 
g paid_receipt_enum = receipt_check==1
rename paid paid_self
replace paid_receipt_enum = 0 if paid_self!=1 // 4 receipts for other taxes
label var paid_receipt_enum "Paid property tax (enumerator validated receipt)"

*Union of these two measures
gen paid_receipt_union = paid_receipt_admin
replace paid_receipt_union=1 if paid_receipt_enum==1
label var paid_receipt_union "Paid property tax (primary measure)"

*Alternative measure for robustness table

label var name_match_only_payer "Paid property tax (admin name match)"

g paid_name_or_receipt_only = name_match_only_payer // This just comes from fuzzy name matching, no code matches
replace paid_name_or_receipt_only=1 if paid_receipt_enum==1 // This comes from showing enumerator valid receipt at endline
label var paid_name_or_receipt_only "Paid property tax (alternative measure)"

*Registration - measured by presence of tax ID code
g registered = compound_code!=999999 & !missing(compound_code)
replace registered = 1 if paid_receipt_union ==1 //Accept all payers with codes on their receipts (we know at one point they had a code)
replace registered = 0 if paid_receipt_enum ==1 & paid_receipt_admin==0  & tax14 ==0

label var registered "Registered as taxpayer"
